<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <fmt:setBundle basename="ApplicationResources"/>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title><fmt:message key="title.maintainUser"/></title>
</head>
<body>
<h2>
    <fmt:message key="title.maintainUser"/>
</h2>
${requestScope.message}
<c:url var="url" scope="page" value="/controller/adduser">
    <c:param name="insert" value="true"/>
</c:url>
<a href="${url}"><fmt:message key="label.maintainuser.add"/></a>
<br/><br/>
<c:if test="${! empty  allUsers}">
    <table class="borderAll">
        <tr>
            <th><fmt:message key="label.maintainuser.index"/></th>
            <th><fmt:message key="label.maintainuser.id"/></th>
            <th><fmt:message key="label.maintainuser.name"/></th>
            <th><fmt:message key="label.maintainuser.edit"/></th>
            <th><fmt:message key="label.maintainuser.delete"/></th>
        </tr>
        <c:forEach var="user" items="${allUsers}" varStatus="status">
            <tr class="${status.index%2==0?'even':'odd'}">
                <td class="nowrap">${status.index + 1}.</td>
                <td class="nowrap">${user.id}</td>
                <td class="nowrap">${user.name}</td>
                <td class="nowrap">
                    <c:url var="edit" scope="page" value="/controller/edituser">
                        <c:param name="id" value="${user.id}"/>
                        <c:param name="name" value="${user.name}"/>
                        <%--<c:param name="roles" value="${user.roles}"/>--%>
                        <%--<c:param name="password" value="${user.password}"/>--%>
                        <c:param name="insert" value="false"/>
                    </c:url>
                    <a href="${edit}"><fmt:message key="label.maintainuser.edit"/></a>
                </td>
                <td class="nowrap">
                    <c:url var="delete" scope="page" value="/controller/deleteuser">
                        <c:param name="id" value="${user.id}"/>
                        <c:param name="insert" value="false"/>
                    </c:url>
                    <a href="${delete}"><fmt:message key="label.maintainuser.delete"/></a>
                </td>
            </tr>
        </c:forEach>
    </table>
</c:if>

</body>
</html>